<?php
class httpEnlightenPlugin
{
	var $uri;
	var $fileList;
	var $metadata;
	
	function httpEnlightenPlugin($uri)
	{
		$this->uri = "$uri";
		$metastring = file_get_contents("$uri/manifest.dat");
		$data = json_decode($metastring,true);
		$this->metadata = $data['metadata'];
		$this->fileList = $data['filelist'];
	}
	
	function ReadMetaData()
	{
		return $this->metadata;		
	}
	
	function ReadFileList()
	{
		foreach($this->fileList as $path=>$version)
		{
			$files[] = $path;
		}
		
		return $files;
	}
	
	function getFileVersion($path)
	{
		return $this->fileList[$path];
	}
	
	function CopyFile($filename, $to)
	{
		$fp = fopen($to, 'wb');
		if(!$fp)
			return false;
		fwrite($fp, file_get_contents("{$this->uri}/$filename"));
		fclose($fp);
		return true;
	}
}
?>